﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:System="clr-namespace:System;assembly=mscorlib"
                    xmlns:Converters="clr-namespace:GraphMyCode.Client.Converters"
                    xmlns:Controls="clr-namespace:GraphMyCode.Client.Controls">

    <Converters:ZoomValueToPercentConverter x:Key="zoomValueToPercentConverter" />

    <Style TargetType="Controls:ImageButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid Height="{TemplateBinding Height}"
                          Width="{TemplateBinding Width}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="normalImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="overImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Visible" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pressedImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="disabledImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Normal">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="normalImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Visible" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="overImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pressedImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="disabledImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="normalImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="overImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pressedImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Visible" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="disabledImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="normalImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="overImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pressedImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="disabledImage"
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                                    Value="Visible" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Unfocused" />
                                <VisualState x:Name="Focused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Image x:Name="normalImage"
                               Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=NormalImage}" />
                        <Image x:Name="disabledImage"
                               Visibility="Collapsed"
                               Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DisabledImage}" />
                        <Image x:Name="overImage"
                               Visibility="Collapsed"
                               Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=MouseOverImage}" />
                        <Image x:Name="pressedImage"
                               Visibility="Collapsed"
                               Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=PressedImage}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Controls:ZoomBox">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <StackPanel Orientation="Vertical">
                        <!--<Controls:ImageButton x:Name="PART_MinusButton"
                                              Visibility="Collapsed"
                                              Height="24"
                                              Width="24"
                                              NormalImage="../Resources/ZoomOut_normal.png"
                                              DisabledImage="../Resources/ZoomOut_disabled.png"
                                              MouseOverImage="../Resources/ZoomOut_over.png"
                                              PressedImage="../Resources/ZoomOut_pressed.png" />-->
                        <Slider Orientation="Vertical"
                                MinHeight="70"
                                Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value, Mode=TwoWay}"
                                LargeChange="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ZoomChange}"
                                Minimum="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=MinValue}"
                                Maximum="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=MaxValue}">
                            <ToolTipService.ToolTip>
                                <ToolTip Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value, Converter={StaticResource zoomValueToPercentConverter}}" />
                            </ToolTipService.ToolTip>
                        </Slider>
                        <!--<Controls:ImageButton x:Name="PART_PlusButton"
                                              Visibility="Collapsed"
                                              Height="24"
                                              Width="24"
                                              NormalImage="../Resources/ZoomIn_normal.png"
                                              DisabledImage="../Resources/ZoomIn_disabled.png"
                                              MouseOverImage="../Resources/ZoomIn_over.png"
                                              PressedImage="../Resources/ZoomIn_pressed.png" />-->

                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Controls:SearchBox">
        <Setter Property="IsTabStop"
                Value="False" />
        <Setter Property="Padding"
                Value="2" />
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="BorderBrush">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0.5,1"
                                     StartPoint="0.5,0">
                    <GradientStop Color="#FFA3AEB9"
                                  Offset="0" />
                    <GradientStop Color="#FF8399A9"
                                  Offset="0.375" />
                    <GradientStop Color="#FF718597"
                                  Offset="0.375" />
                    <GradientStop Color="#FF617584"
                                  Offset="1" />
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Background"
                Value="#FFFFFFFF" />
        <Setter Property="Foreground"
                Value="#FF000000" />
        <Setter Property="MinWidth"
                Value="45" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:SearchBox">
                    <Grid Opacity="{TemplateBinding Opacity}">
                        <Border Padding="{TemplateBinding Padding}"
                                Background="{TemplateBinding Background}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <!--NOTE Image for search-->
                                <Image Margin="1"
                                       Grid.Column="0"
                                       Width="16"
                                       Height="16" />

                                <TextBlock x:Name="PART_EmptyText"
                                           Grid.Column="1"
                                           Visibility="Visible"
                                           Foreground="White"
                                           FontStyle="Italic"
                                           Text="Search..."
                                           VerticalAlignment="Center" />

                                <TextBox x:Name="Text"
                                         Grid.Column="1"
                                         Margin="0"
                                         IsTabStop="True"
                                         Background="Transparent"
                                         Foreground="{TemplateBinding Foreground}"
                                         CaretBrush="White"
                                         BorderThickness="0">
                                    <TextBox.Style>
                                        <Style TargetType="TextBox">
                                            <Setter Property="BorderThickness"
                                                    Value="1" />
                                            <Setter Property="Background"
                                                    Value="#FFFFFFFF" />
                                            <Setter Property="Foreground"
                                                    Value="#FF000000" />
                                            <Setter Property="Padding"
                                                    Value="2" />
                                            <Setter Property="BorderBrush">
                                                <Setter.Value>
                                                    <LinearGradientBrush EndPoint="0.5,1"
                                                                         StartPoint="0.5,0">
                                                        <GradientStop Color="#FFA3AEB9"
                                                                      Offset="0" />
                                                        <GradientStop Color="#FF8399A9"
                                                                      Offset="0.375" />
                                                        <GradientStop Color="#FF718597"
                                                                      Offset="0.375" />
                                                        <GradientStop Color="#FF617584"
                                                                      Offset="1" />
                                                    </LinearGradientBrush>
                                                </Setter.Value>
                                            </Setter>
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="TextBox">
                                                        <Grid x:Name="RootElement">
                                                            <VisualStateManager.VisualStateGroups>
                                                                <VisualStateGroup x:Name="CommonStates">
                                                                    <VisualState x:Name="Normal" />
                                                                    <VisualState x:Name="MouseOver">
                                                                        <Storyboard>
                                                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="MouseOverBorder"
                                                                                                          Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
                                                                                <SplineColorKeyFrame KeyTime="0"
                                                                                                     Value="#FF99C1E2" />
                                                                            </ColorAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Disabled">
                                                                        <Storyboard>
                                                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledVisualElement"
                                                                                                           Storyboard.TargetProperty="Opacity">
                                                                                <SplineDoubleKeyFrame KeyTime="0"
                                                                                                      Value="1" />
                                                                            </DoubleAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="ReadOnly">
                                                                        <Storyboard>
                                                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ReadOnlyVisualElement"
                                                                                                           Storyboard.TargetProperty="Opacity">
                                                                                <SplineDoubleKeyFrame KeyTime="0"
                                                                                                      Value="1" />
                                                                            </DoubleAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                </VisualStateGroup>
                                                                <VisualStateGroup x:Name="FocusStates">
                                                                    <VisualState x:Name="Focused">
                                                                        <Storyboard>
                                                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement"
                                                                                                           Storyboard.TargetProperty="Opacity">
                                                                                <SplineDoubleKeyFrame KeyTime="0"
                                                                                                      Value="1" />
                                                                            </DoubleAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Unfocused">
                                                                        <Storyboard>
                                                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement"
                                                                                                           Storyboard.TargetProperty="Opacity">
                                                                                <SplineDoubleKeyFrame KeyTime="0"
                                                                                                      Value="0" />
                                                                            </DoubleAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                </VisualStateGroup>
                                                                <VisualStateGroup x:Name="ValidationStates">
                                                                    <VisualState x:Name="Valid" />
                                                                    <VisualState x:Name="InvalidUnfocused">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement"
                                                                                                           Storyboard.TargetProperty="Visibility">
                                                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                                                    <DiscreteObjectKeyFrame.Value>
                                                                                        <Visibility>Visible</Visibility>
                                                                                    </DiscreteObjectKeyFrame.Value>
                                                                                </DiscreteObjectKeyFrame>
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="InvalidFocused">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement"
                                                                                                           Storyboard.TargetProperty="Visibility">
                                                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                                                    <DiscreteObjectKeyFrame.Value>
                                                                                        <Visibility>Visible</Visibility>
                                                                                    </DiscreteObjectKeyFrame.Value>
                                                                                </DiscreteObjectKeyFrame>
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip"
                                                                                                           Storyboard.TargetProperty="IsOpen">
                                                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                                                    <DiscreteObjectKeyFrame.Value>
                                                                                        <System:Boolean>True</System:Boolean>
                                                                                    </DiscreteObjectKeyFrame.Value>
                                                                                </DiscreteObjectKeyFrame>
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                </VisualStateGroup>
                                                            </VisualStateManager.VisualStateGroups>
                                                            <Border x:Name="Border"
                                                                    Opacity="1"
                                                                    Background="{TemplateBinding Background}"
                                                                    BorderBrush="{TemplateBinding BorderBrush}"
                                                                    BorderThickness="0"
                                                                    CornerRadius="1">
                                                                <Grid>
                                                                    <Border x:Name="ReadOnlyVisualElement"
                                                                            Opacity="0"
                                                                            Background="#5EC9C9C9" />
                                                                    <Border x:Name="MouseOverBorder"
                                                                            BorderBrush="Transparent"
                                                                            BorderThickness="0">
                                                                        <ScrollViewer x:Name="ContentElement"
                                                                                      BorderThickness="0"
                                                                                      IsTabStop="False"
                                                                                      Padding="{TemplateBinding Padding}" />
                                                                    </Border>
                                                                </Grid>
                                                            </Border>
                                                            <Border x:Name="DisabledVisualElement"
                                                                    IsHitTestVisible="False"
                                                                    Opacity="0"
                                                                    Background="#A5F7F7F7"
                                                                    BorderBrush="#A5F7F7F7"
                                                                    BorderThickness="{TemplateBinding BorderThickness}" />
                                                            <Border x:Name="FocusVisualElement"
                                                                    Margin="1"
                                                                    IsHitTestVisible="False"
                                                                    Opacity="0"
                                                                    BorderBrush="#FF6DBDD1"
                                                                    BorderThickness="0" />
                                                            <Border x:Name="ValidationErrorElement"
                                                                    Visibility="Collapsed"
                                                                    BorderBrush="#FFDB000C"
                                                                    BorderThickness="1"
                                                                    CornerRadius="1">

                                                                <Grid Height="12"
                                                                      HorizontalAlignment="Right"
                                                                      Margin="1,-4,-4,0"
                                                                      VerticalAlignment="Top"
                                                                      Width="12"
                                                                      Background="Transparent">
                                                                    <Path Fill="#FFDC000C"
                                                                          Margin="1,3,0,0"
                                                                          Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" />
                                                                    <Path Fill="#ffffff"
                                                                          Margin="1,3,0,0"
                                                                          Data="M 0,0 L2,0 L 8,6 L8,8" />
                                                                </Grid>
                                                            </Border>
                                                        </Grid>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </TextBox.Style>
                                </TextBox>
                                <Button x:Name="PART_ClearButton"
                                        Margin="0"
                                        Grid.Column="2"
                                        Visibility="Collapsed">
                                    <Button.Style>
                                        <Style TargetType="Button">
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="Button">
                                                        <Grid>
                                                            <VisualStateManager.VisualStateGroups>
                                                                <VisualStateGroup x:Name="CommonStates">
                                                                    <VisualState x:Name="MouseOver">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_ClearButtonImage"
                                                                                                           Storyboard.TargetProperty="Source"
                                                                                                           Duration="0">
                                                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                                                        Value="Resources/close_over.png" />
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Normal">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_ClearButtonImage"
                                                                                                           Storyboard.TargetProperty="Source"
                                                                                                           Duration="0">
                                                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                                                        Value="Resources/close_normal.png" />
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Pressed">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_ClearButtonImage"
                                                                                                           Storyboard.TargetProperty="Source"
                                                                                                           Duration="0">
                                                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                                                        Value="Resources/close_pressed.png" />
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Disabled">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_ClearButtonImage"
                                                                                                           Storyboard.TargetProperty="Source"
                                                                                                           Duration="0">
                                                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                                                        Value="Resources/close_normal.png" />
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                </VisualStateGroup>
                                                                <VisualStateGroup x:Name="FocusStates">
                                                                    <VisualState x:Name="Unfocused" />
                                                                    <VisualState x:Name="Focused" />
                                                                </VisualStateGroup>
                                                            </VisualStateManager.VisualStateGroups>
                                                            <Image x:Name="PART_ClearButtonImage" />
                                                        </Grid>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </Button.Style>
                                </Button>
                            </Grid>
                        </Border>
                        <Popup x:Name="Popup">
                            <Grid Opacity="{TemplateBinding Opacity}">
                                <Border x:Name="PopupBorder"
                                        HorizontalAlignment="Stretch"
                                        Opacity="0"
                                        BorderThickness="0">
                                    <Border.RenderTransform>
                                        <TranslateTransform X="1"
                                                            Y="1" />
                                    </Border.RenderTransform>
                                    <Border.Background>
                                        <SolidColorBrush Color="#11000000" />
                                    </Border.Background>
                                    <Border HorizontalAlignment="Stretch"
                                            Opacity="1.0"
                                            Padding="0"
                                            BorderThickness="{TemplateBinding BorderThickness}"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            CornerRadius="0">
                                        <Border.RenderTransform>
                                            <TransformGroup>
                                                <TranslateTransform X="-1"
                                                                    Y="-1" />
                                            </TransformGroup>
                                        </Border.RenderTransform>
                                        <Border.Background>
                                            <LinearGradientBrush EndPoint="0.5,1"
                                                                 StartPoint="0.5,0">
                                                <GradientStop Color="#77DDDDDD"
                                                              Offset="0" />
                                                <GradientStop Color="#22DDDDDD"
                                                              Offset="1" />
                                            </LinearGradientBrush>
                                        </Border.Background>
                                        <ListBox x:Name="Selector"
                                                 ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                                 ScrollViewer.VerticalScrollBarVisibility="Auto"
                                                 ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
                                                 Background="{TemplateBinding Background}"
                                                 Foreground="{TemplateBinding Foreground}"
                                                 BorderThickness="0"
                                                 ItemTemplate="{TemplateBinding ItemTemplate}" />
                                    </Border>
                                </Border>
                            </Grid>
                        </Popup>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="PopupStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.1"
                                                      To="PopupOpened" />
                                    <VisualTransition GeneratedDuration="0:0:0.2"
                                                      To="PopupClosed" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="PopupOpened">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="PopupBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1.0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="PopupClosed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="PopupBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="0.0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>

                            <VisualStateGroup x:Name="TextStates">
                                <VisualState x:Name="TextEmpty">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_EmptyText"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame Value="Visible"
                                                                    KeyTime="0" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                
                                <VisualState x:Name="TextNonEmpty">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_EmptyText"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame Value="Collapsed"
                                                                    KeyTime="0" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>

                            <VisualStateGroup x:Name="ClearButtonStates">
                                <VisualState x:Name="ButtonVisible">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_ClearButton"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame Value="Visible"
                                                                    KeyTime="0">
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="ButtonHidden" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
